#include "PushTarget.h"

void PushTarget::AddObserver(IPushObserver& observer)
{
	_observers.push_back(&observer);
}

void PushTarget::RemoveObserver(IPushObserver& observer)
{
	std::erase_if(_observers, [&](auto it) { return it == &observer; });
}

void PushTarget::SetEvent(const Event& event)
{
	_event = event;
	Notify();
}

void PushTarget::Notify() const
{
	auto observers = std::vector<IPushObserver*>(_observers);
	for (auto observer : observers)
	{
		observer->OnEvent(*this, _event);
	}
}
